package com.ftdigital.primemovers_operators.util.loading;

import android.app.AlertDialog;
import android.content.Context;
import android.view.Window;
import android.view.WindowManager;

import com.ftdigital.primemovers_operators.R;


/**
 * Created by Curry on 2015/8/20.
 */


public class Loading {
    private static RotateLoading rotateLoading;
    private static AlertDialog alertDialog;
    public static Context context;
    private static boolean isLoadingFlag = false;
    public static void startLoading() {
        alertDialog = new AlertDialog.Builder(context)
                .create();
        alertDialog.show();
        Window window = alertDialog.getWindow();
        window.setContentView(R.layout.loading_dialog);
        window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        rotateLoading = (RotateLoading) window.findViewById(R.id.rotateloading);
        isLoadingFlag = true;
        rotateLoading.start();
    }

    public static void stopLoading(){
        isLoadingFlag = false;
        alertDialog.dismiss();
        rotateLoading.start();
    }

    public static boolean isLoading(){
        return isLoadingFlag;
    }


}
